package com.mobilesalon.tools;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DateTools {

	public static final DateFormat TIMESTAMP_DATEFORMAT = new SimpleDateFormat(
			"yyyy-MM-dd HH:mm:ss");
	public static final DateFormat DATE_REVERSE_DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd");
	public static final DateFormat DATE_DATEFORMAT = new SimpleDateFormat("dd/MM/yyyy");
	public static final DateFormat TIME_DATEFORMAT = new SimpleDateFormat("HH:mm");
	public static final DateFormat MONTH_DATEFORMAT = new SimpleDateFormat("MM/yyyy");

	public static final Calendar roundByDay(Calendar calendar) {
		calendar.set(Calendar.HOUR_OF_DAY, 0 );
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);

		return calendar;
	}
	
	public static final Calendar roundByMonth(Calendar calendar) {
		calendar.set(Calendar.DAY_OF_MONTH, 1 );
		calendar.set(Calendar.HOUR_OF_DAY, 0 );
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);

		return calendar;
	}
}
